'''
Created on Sep 27, 2009

@author: mkiyer
'''


from veggie.app.rnaseq.tophat import TopHat
from optparse import OptionParser
import sys
import os

if __name__ == '__main__':
    optionparser = OptionParser("usage: %prog [options] <mate1-fastq,[mate2-fastq],...>")
    optionparser.add_option("-o", "--output-dir",
                            dest="output_dir",
                            default=os.path.curdir)
    optionparser.add_option("-p", dest="processors", type="int",
                            default="4",
                            help="number of processors to run job [default=%default]")
    optionparser.add_option("--mode", dest="mode",
                            default="single-best",
                            help="alignment mode: single-best,"
                            "paired-end [default: %default]")
    optionparser.add_option("--quals", dest="quals",
                            default="solexa-quals",
                            help="format of quality scores: solexa-quals,"
                            "solexa1.3-quals, [default: %default]")
    optionparser.add_option("--genome", dest="genome",
                            default="hg18",
                            help="indexes to use for mapping: "
                                 "hg18 [default: %default]")
    (options, args) = optionparser.parse_args()

    # options
    tophat_options = {'-p': options.processors,
                      '--' + options.quals: None}
    # create the app controller
    tophat_app = TopHat(options=tophat_options)
    
    # run on test data
    if options.mode == "single-best":   
        tophat_app.run_single_best(args[0], 
                                   output_dir=options.output_dir,
                                   genome=options.genome)
    elif options.mode == "paired-end":
        tophat_app.run_paired_end(args[0], args[1], 
                                  output_dir=options.output_dir,
                                  genome=options.genome)